package com.fengyunhe.manager.dao.entity;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * 功能：
 * 作者： yangyan
 * 时间： 2014/9/5 .
 */
@Entity
@Table(name = "admin_role_perm_bind")
public class AdminRolePermBindEntity {
    private String relId;
    private String perm;
    private Timestamp createdAt;
    private Integer createdByUserId;
    private String createdByRealName;
    private AdminRoleEntity adminRoleByRoleId;
    @GenericGenerator(name = "generator", strategy = "uuid.hex")
    @GeneratedValue(generator = "generator")
    @Id
    @Column(name = "rel_id", nullable = false, insertable = true, updatable = true, length = 36)
    public String getRelId() {
        return relId;
    }

    public void setRelId(String relId) {
        this.relId = relId;
    }

    @Basic
    @Column(name = "perm", nullable = true, insertable = true, updatable = true, length = 100)
    public String getPerm() {
        return perm;
    }

    public void setPerm(String perm) {
        this.perm = perm;
    }

    @Basic
    @Column(name = "created_at", nullable = true, insertable = true, updatable = true)
    public Timestamp getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.createdAt = createdAt;
    }

    @Basic
    @Column(name = "created_by_user_id", nullable = true, insertable = true, updatable = true)
    public Integer getCreatedByUserId() {
        return createdByUserId;
    }

    public void setCreatedByUserId(Integer createdByUserId) {
        this.createdByUserId = createdByUserId;
    }

    @Basic
    @Column(name = "created_by_real_name", nullable = true, insertable = true, updatable = true, length = 36)
    public String getCreatedByRealName() {
        return createdByRealName;
    }

    public void setCreatedByRealName(String createdByRealName) {
        this.createdByRealName = createdByRealName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        AdminRolePermBindEntity that = (AdminRolePermBindEntity) o;

        if (createdAt != null ? !createdAt.equals(that.createdAt) : that.createdAt != null) return false;
        if (createdByRealName != null ? !createdByRealName.equals(that.createdByRealName) : that.createdByRealName != null)
            return false;
        if (createdByUserId != null ? !createdByUserId.equals(that.createdByUserId) : that.createdByUserId != null)
            return false;
        if (perm != null ? !perm.equals(that.perm) : that.perm != null) return false;
        if (relId != null ? !relId.equals(that.relId) : that.relId != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = relId != null ? relId.hashCode() : 0;
        result = 31 * result + (perm != null ? perm.hashCode() : 0);
        result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
        result = 31 * result + (createdByUserId != null ? createdByUserId.hashCode() : 0);
        result = 31 * result + (createdByRealName != null ? createdByRealName.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "role_id", referencedColumnName = "role_id")
    public AdminRoleEntity getAdminRoleByRoleId() {
        return adminRoleByRoleId;
    }

    public void setAdminRoleByRoleId(AdminRoleEntity adminRoleByRoleId) {
        this.adminRoleByRoleId = adminRoleByRoleId;
    }
}
